var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var r in t) t.hasOwnProperty(r) && (e[r] = t[r]);
    })(e, t);
}, function(e, t) {
    function r() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (r.prototype = t.prototype, 
    new r());
}), a = this && this.__decorate || function(e, t, r, n) {
    var a, i = arguments.length, o = i < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, r) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) o = Reflect.decorate(e, t, r, n); else for (var l = e.length - 1; 0 <= l; l--) (a = e[l]) && (o = (i < 3 ? a(o) : 3 < i ? a(t, r, o) : a(t, r)) || o);
    return 3 < i && o && Object.defineProperty(t, r, o), o;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = e("Global"), c = cc._decorator, l = c.ccclass, d = c.property, u = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.nameLabel = null, e.starLabel = null, e.numSprite = null, e.headSprite = null, 
        e.levelSprite = null, e.default = null, e.data = null, e.isStart = !1, e;
    }
    return i(e, t), e.prototype.init = function(e) {
        this.data = e, this.refresh();
    }, e.prototype.refresh = function() {
        var t, e, n = this;
        this.isStart && (cc.log("init seasonTopItem"), (e = this.data).rank && (1 == e.rank ? (t = new cc.Node().addComponent(sp.Skeleton), 
        r.default.getInstance().loadRes({
            url: "skeleton/rank/skeleton",
            type: sp.SkeletonData
        }).then(function(e) {
            t && (t.skeletonData = e, t.node.parent = n.node, t.node.position = n.numSprite.node.position, 
            t.setAnimation(0, "animation", !0));
        })) : r.default.getInstance().loadSpriteFrame({
            url: "image/num/rank/" + e.rank + "@2x",
            sprite: this.numSprite
        })), !s.G.isNative() && "" != e.avatarUrl.trim() || isNaN(e.personIdx) ? e.avatarUrl ? r.default.getInstance().loadImage({
            url: e.avatarUrl
        }).then(function(e) {
            n.headSprite && e instanceof cc.Texture2D ? n.headSprite.spriteFrame = new cc.SpriteFrame(e) : cc.log(e);
        }).catch(function(e) {
            console.error(e);
        }) : this.headSprite.spriteFrame = this.default : isNaN(e.personIdx) ? r.default.getInstance().loadSpriteFrame({
            url: "image/skin/" + s.G.personModelList[GA.rand(0, s.G.personModelList.length - 1)].id,
            sprite: this.headSprite
        }) : r.default.getInstance().loadSpriteFrame({
            url: "image/skin/" + e.personIdx,
            sprite: this.headSprite
        }), e.nickname ? 5 < e.nickname.length ? this.nameLabel.string = e.nickname.substring(0, 5) + "..." : this.nameLabel.string = e.nickname : this.nameLabel.string = "未授权", 
        null != e.level && (this.starLabel.string = " x " + e.level, e = s.G.getRank(e.level), 
        r.default.getInstance().loadSpriteFrame({
            url: "image/level/" + e.r,
            sprite: this.levelSprite
        })));
    }, e.prototype.start = function() {
        this.isStart = !0, this.refresh();
    }, a([ d(cc.Label) ], e.prototype, "nameLabel", void 0), a([ d(cc.Label) ], e.prototype, "starLabel", void 0), 
    a([ d(cc.Sprite) ], e.prototype, "numSprite", void 0), a([ d(cc.Sprite) ], e.prototype, "headSprite", void 0), 
    a([ d(cc.Sprite) ], e.prototype, "levelSprite", void 0), a([ d(cc.SpriteFrame) ], e.prototype, "default", void 0), 
    a([ l ], e);
}(cc.Component);

n.default = u;